-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PoC] Interfacing GHDL to other languages: declaration of foreign C functions #465
base: master
Are you sure you want to change the base?
Conversation
Apart from the copyright issues, I think that the acceptance tests are failing because the GHDL version being used at appveyor is v0.35. I could successfully execute them with |
It is possible to set a sim_option for just one test case or test bench so you do not have to set it for all test benches. Regarding adding support for invoking GCC from VUnit I do not think it makes sense. For building C-code there already lots of tools out there and it does not seem worth the effort to add dependency scanning, build rules, compiler flag settings etc for GCC to VUnit. You could just call an external makefile from the run.py file to build any C-code. Regarding '--elaborate' the GHDL binary must be called for elaboration to be performed. I guess in this example since you are wrapping the GHDL main function with data generation and checking you need to check the ARGV and skip data generation and checking unless the run flag was given. |
Thanks. I'll look for the correct syntax to do so.
I agree that it is possible, and desirale indeed, to rely on external makefiles, cmakes, etc. This is specially so because foreign declarations can be written not only in C, but in multiple other languages. Hence, I did not explain myself properly. I meant adding
I opened a new issue to discuss this. Please see #466. |
Wouldnt the user want to specify unique .o files for each testbench/test. Then all of them cannot be automatically added. |
Now, the elaboration flag
In the current implementation of the external memory model, I provide different sets of |
f4c7f2c
to
14f9c2e
Compare
@kraigher, I think this is ready for review now. As you see, I replaced the protected shared variables with a There are three implementation details wich I am not completely happy with, but I couldn't guess how to do it better:
In the "traditional testbench", |
b365c63
to
a241e7d
Compare
f404935
to
0668430
Compare
bacca8f
to
2649cdf
Compare
d5df67c
to
a3f2e3f
Compare
d51c831
to
0694f40
Compare
0694f40
to
e31e7e0
Compare
f4f5c70
to
c5b75cb
Compare
…ed by both tb_py_* and tb_c_*
c5b75cb
to
acbbd1c
Compare
This PR is an example of how users can use GHDL + VUnit + VHPIDIRECT without built-in types. For practical cases, using
string_ptr
,byte_vector_ptr
and/orinteger_vector_ptr
instead is recommended. See #507, #476.Using 1138-4EB/hwd-ide/tree/examples-vhpi/examples/VHPI as a reference, this PR extends example
array_axis_vcs
to use data defined in a foreign C function. Moreover, the entrypoint to the binary is a foreignmain
function, instead of the (default)ghdl_main
.tb_axis_loop.vhd
is renamed totb_py_axis_loop.vhd
.tb_vc_axis_loop.vhd
tb_c_axis_loop.vhd
is added. This is equivalent totb_py_axis_loop.vhd
but, instead of reading/writing data from/to CSV files, data is generated in some C function and the output is evaluated in another C function.pkg_c.vhd
, the equivalencies between VHDL functions/types and the foreign resources are declared.run.py
is modified in order to first build the C sources to an object and then pass the object to GHDL for elaboration.These examples are functional ATM. However, there are some issues that can be improved:
py
testbench is also being executed through the foreignmain
function. This is not required, and it should be avoided.I find it ugly to execute GCC explicitly in the. How to provide different sets of C objects to several testbenches: some of the C sources are common, and some are specific for each testbench. This is implemented in [3/3] Support up to N external memory models #470.run.py
. I'd rather add the C sources as any other source (lib.add_source_files(join(root, "src/**/*.c"))
and let VUnit handle it. However, I don't know if this can work with other simulators that support VHPI, or is something specific to GHDL. @kraigher, is this something you would like to support? Note that this same approach can be used to, e.g., let the simulation draw images in a window during simulation (see xvga)python3 run.py -v --elaborate
, the application (main
) is executed, but GHDL is skipped, so the check fails. I would expect the binary not to be executed at all. [add sim_opt 'ghdl.elab_e' to run 'ghdl -e' instead of 'ghdl --elab-run --no-run' #467]main.c
and/ortb_c_axis_loop.vhd
should be updated in order to fix this. See fix: nonzero return values should produce a fail #469.I'm now building an example that uses AXI Master, instead of AXI Stream, in order to try the alternative memory model as commented at #462. Is there any AXI Master IP in the VUnit codebase which I can use as a UUT?See #462 (comment)